#include <iostream>
#include "resnet.h"
#include <chrono>
#include <filesystem>

int main()
{
    // 初始化
    ResNet net("static/models/resnet/test.onnx", "classfication.names"); // 网络
    std::string imgDir = "static/images/service_area/visitor";           // 图片目录
    auto start = std::chrono::high_resolution_clock::now();              // 计时器
    int numImages = 0;                                                   // 图片张数

    // 遍历图片目录
    for (const auto &entry : std::filesystem::directory_iterator(imgDir))
    {
        numImages++;
        std::string imgpath = entry.path().string();
        cv::Mat srcimg = cv::imread(imgpath);
        int index = net.detect(srcimg);
        std::cout << "Image: " << imgpath << ", Prediction: " << net.class_names[index] << std::endl;
    }
    // 输出用时
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> duration = end - start;
    std::cout << "总的推理时间： " << duration.count() << " 秒" << std::endl;
    std::cout << "图片的张数： " << numImages << " 张" << std::endl;
    std::cout << "每张图片推理时间： " << duration.count() / numImages << " 秒" << std::endl;
    return 0;
}
